package com.gupao.javavip.gof.singleton;

/**
 * 饿汉式单例模式
 * <p>
 * 优点：简单直接，线程安全
 * 缺点：类初始化时变实例化，提前占用了存储空间，可能造成浪费
 * <p>
 * 这里未进行防反射破坏单例处理
 */
public class HungrySingletonConstructorUnSafe {
    //static保证类初始化时便实例化
    private static final HungrySingletonConstructorUnSafe INSTANCE = new HungrySingletonConstructorUnSafe();

    //构造方法私有化
    private HungrySingletonConstructorUnSafe() {
    }

    //提供全局访问点
    public static HungrySingletonConstructorUnSafe getInstance() {
        return INSTANCE;
    }
}
